package com.ys.多线程.p1线程守护;

/**
 * 描述:
 *
 * @author CodeYang
 * @version 2021/1/5 10:06
 */
public class P1ThreadDaemon  {

    public static void main(String[] args) {
        FrontTread frontTread = new FrontTread();
        DaemonThread daemonThread = new DaemonThread();
        frontTread.start();
        daemonThread.setDaemon(true);
        daemonThread.start();

    }
}

class FrontTread extends  Thread {


    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("-------前台线程第" + i + "次执行！");
        }
    }
}

class DaemonThread extends  Thread{
    int i = 0;
    @Override
    public void run() {
        while(true) {
            System.out.println("后台线程第" + i++ + "次执行！");
        }
    }
}
